package com.ruoyi.project.student.controller;

import java.util.List;
import javax.servlet.http.HttpServletResponse;
import org.springframework.security.access.prepost.PreAuthorize;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.PutMapping;
import org.springframework.web.bind.annotation.DeleteMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import com.ruoyi.framework.aspectj.lang.annotation.Log;
import com.ruoyi.framework.aspectj.lang.enums.BusinessType;
import com.ruoyi.project.student.domain.Student;
import com.ruoyi.project.student.domain.StudentVo;
import com.ruoyi.project.student.service.IStudentService;
import com.ruoyi.framework.web.controller.BaseController;
import com.ruoyi.framework.web.domain.AjaxResult;
import com.ruoyi.common.utils.poi.ExcelUtil;
import com.ruoyi.framework.web.page.TableDataInfo;

/**
 * 学生管理系统Controller
 * 
 * @author ning
 * @date 2025-03-20
 */
@RestController
@RequestMapping("/student/student")
public class StudentController extends BaseController
{
    @Autowired
    private IStudentService studentService;

    /**
     * 查询学生列表
     */
    @PreAuthorize("@ss.hasPermi('student:student:list')")
    @GetMapping("/list")
    public TableDataInfo list(StudentVo studentvo)
    {
        startPage();
        List<StudentVo> list = studentService.selectStudentList(studentvo);
        return getDataTable(list);
    }

    /**
     * 新增学生
     */
    @PreAuthorize("@ss.hasPermi('student:student:add')")
    @Log(title = "学生管理系统", businessType = BusinessType.INSERT)
    @PostMapping("/addStudent")
    public AjaxResult add(@RequestBody StudentVo studentvo)
    {
        return toAjax(studentService.insertStudent(studentvo));
    }

    /**
     * 修改学生
     */
    @PreAuthorize("@ss.hasPermi('student:student:edit')")
    @PostMapping("/editStudent")
    public AjaxResult edit(@RequestBody Student student)
    {
        return toAjax(studentService.editStudent(student));
    }

    /**
     * 删除学生
     */
    @PreAuthorize("@ss.hasPermi('student:student:del')")
    @PostMapping("/delStudent")
    public AjaxResult del(@RequestBody Student student)
    {
        return toAjax(studentService.deleteStudent(student));
    }

}
